﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryKSTAGZUO(DataRow dwData, int option = 1)
        {
            DataSet Return = new DataSet();
            DataTable tbLocal = null;
            DataSet Result = new DataSet();

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM KSTAGZUO WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM KSTAGZUO WHERE  "
                        + "  KSZMANDANT=:KSZMANDANT AND KSZLIEFNR=:KSZLIEFNR";
                    or1.Parameters.Add("KSZMANDANT", OracleType.NVarChar).Value = dwData["KSZMANDANT"].ToString();
                    or1.Parameters.Add("KSZLIEFNR", OracleType.NVarChar).Value = dwData["KSZLIEFNR"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT DISTINCT KSZMANDANT, KSZKSTKRS,KSZKST,KSZAGANG, KSZLO,KSZLB,KSZLP FROM KSTAGZUO WHERE  "
                        + "  KSZMANDANT=:KSZMANDANT";
                    or1.Parameters.Add("KSZMANDANT", OracleType.NVarChar).Value = dwData["KSZMANDANT"].ToString();
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "KSTAGZUO";
            }
            Return.Merge(Result);

            return Return;
        }
    }
}
